package cn.cdyx.common.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @Author Watermelon
 * @Date 2023-01-19 10:22
 * 系统日志类
 */
public class SystemLog implements Serializable {
    //操作描述
    private String description;
    //操作用户
    private String username;
    //操作时间
    private LocalDateTime startTime;
    //访问的方法
    private String sysMethod;
    //消耗时间（毫秒）
    private long spendTime;
    //URI
    private String uri;
    //URL
    private String url;
    //请求类型
    private String method;
    //IP地址
    private String ip;
    //请求参数
    private Object parameter;
    //请求返回的结果
    private Object result;

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public LocalDateTime getStartTime() {
        return startTime;
    }

    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }

    public String getSysMethod() {
        return sysMethod;
    }

    public void setSysMethod(String sysMethod) {
        this.sysMethod = sysMethod;
    }

    public long getSpendTime() {
        return spendTime;
    }

    public void setSpendTime(long spendTime) {
        this.spendTime = spendTime;
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public Object getParameter() {
        return parameter;
    }

    public void setParameter(Object parameter) {
        this.parameter = parameter;
    }

    public Object getResult() {
        return result;
    }

    public void setResult(Object result) {
        this.result = result;
    }

    @Override
    public String toString() {
        DateTimeFormatter dfDateTime = DateTimeFormatter.ofPattern(Code.SYSTEM_DATATIME_PATTERN);
        return " SystemLog{" + '\n' +
                " 操作描述='" + description + "'," + '\n' +
                " 操作用户='" + username + "'," + '\n' +
                " 操作时间=" + dfDateTime.format(startTime) + "," + '\n' +
                " 调用方法='" + sysMethod + "'," + '\n' +
                " 消耗时间='" + spendTime + "毫秒" + "'," + '\n' +
                " uri='" + uri + "'," + '\n' +
                " url='" + url + "'," + '\n' +
                " 请求方式='" + method + "'," + '\n' +
                " ip地址='" + ip + "'," + '\n' +
                " 入参='" + parameter + "'," + '\n' +
                " 返回值=" + result + '\n' +
                " }";
    }
}
